import React, { FC, useRef } from "react"

const Demo: FC = () => {
  const inputRef = useRef<HTMLInputElement>(null)
  function selectInput() {
    const inputElem = inputRef.current
    console.log(inputElem)
    if (inputElem) inputElem.select()  //Dom节点，DOM 操作API
  }
  return (
    <div>
      <input ref={inputRef} defaultValue="hello world" />
      <button onClick={selectInput}>选中</button>
    </div>
  )
}


export default Demo
